from sqlalchemy import Column, Integer, String, DateTime
from datetime import datetime
from core.base.orm_model import Base, TimestampMixin

class User(Base, TimestampMixin):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True, index=True)
    username = Column(String(50), unique=True, index=True, nullable=False)
    name = Column(String(50))
    avatar = Column(String(255))
    email = Column(String(100), unique=True, index=True)
    phone = Column(String(20))
    password = Column(String(100), nullable=False)
    status = Column(Integer, default=1)
    department = Column(String(50))
    person_id = Column(Integer)
    create_time = Column(DateTime, default=datetime.now, comment="创建时间")
    update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")

    def __repr__(self):
        return f"<User {self.username}>"